function Bird(ctx) {
  this.x = 1200;
  this.y = 0; 
  this.w = 83;
  this.h = 78;
  this.ctx = ctx;
  this.n = 0; // 记录帧数 
  this.index = 0; // 图片索引 用于动画图片
  this.speed = 10;  
  this.init();
  this.distance = randomNum(300, 800)
}



Bird.prototype = {
  init() {
    let n = randomNum(1, 10)
    // 随机 高中低 
    if (n <=3) {
      this.y = 20
    } else if (n <=6) {
      this.y = 100
    } else {
      this.y = 180;
    }
  },

  draw() {  
    this.n++;
    // let index = 0;
    if (this.n % 20==0) {
      console.log('n:', this.n);
      if (this.index === 0) {
        this.index = 1;
      
      } else {
        this.index = 0;
      }
    }
    this.collisionList = BirdCollisionList[this.index];
    this.ctx.drawImage(imgSprite , birdSprite[this.index].x, birdSprite[this.index].y, this.w, this.h, this.x, this.y , this.w, this.h);
    this.ctx.lineWidth = 0.5;
    this.ctx.strokeStyle = 'green';
    if (this.red) {
      this.ctx.strokeStyle = 'red';
    }
    // // this.ctx.strokeRect(this.x, this.y, this.w, this.h);
    this.collisionList.forEach(v=>{
      // // this.ctx.strokeRect(this.x + v.x, this.y + v.y, v.w, v.h);
    })
    this.move();
  },

  // 移动
  move () {
    this.x -= this.speed;
  }
}